﻿# coding:utf-8

#处理分页的URL
class PageUrlManager(object):
	def __init__(self):
		self.new_url_set = set()
		self.old_url_set = set()
	
	def add_new_url(self, url):
		if url is None or url in self.old_url_set:
			return
		self.new_url_set.add(url)
	
	def add_new_urls(self,category_url,count):
		index = 1
		while index <= count:
			url = category_url + '_' + str(index)
			#print url
			self.add_new_url(url)
			index = index + 1
		
	def has_new_url(self):
		if self.new_url_set is None or len(self.new_url_set)==0:
			return False
		return True
	
	def get_new_url(self):
		if self.new_url_set is None or len(self.new_url_set)==0:
			return False
		url = self.new_url_set.pop()
		self.old_url_set.add(url)
		return url